/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.crystalrange.documents.service.impl;

import com.googlecode.genericdao.search.Search;
import com.googlecode.genericdao.search.SearchResult;
import java.util.Date;
import java.util.List;
import org.crystalrange.documents.dao.DocumentTypeDao;
import org.crystalrange.documents.model.DocumentType;
import org.crystalrange.documents.service.DocumentTypeService;
import org.crystalrange.model.User;
import org.crystalrange.service.UserService;

/**
 *
 * @author Krzysiek
 */
public class DocumentTypeServiceImpl implements DocumentTypeService {

    private DocumentTypeDao documentTypeDao;
    private UserService userService;

    public DocumentTypeDao getDocumentTypeDao() {
        return documentTypeDao;
    }

    public void setDocumentTypeDao(DocumentTypeDao documentTypeDao) {
        this.documentTypeDao = documentTypeDao;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    
    public DocumentType create(String username) {
        User currentUser = this.userService.findByUsername(username);   
        
        DocumentType documentType = new DocumentType();
        documentType.setCreatedBy(currentUser);
        documentType.setCreatedDate(new Date());
        
        return documentType;
    }

    public boolean save(DocumentType documentType) {
        return this.documentTypeDao.save(documentType);
    }

    public boolean remove(DocumentType documentType) {
        return this.documentTypeDao.remove(documentType);
    }

    public DocumentType find(Long id) {
        return this.documentTypeDao.find(id);
    }

    public List<DocumentType> findAll() {
        return this.documentTypeDao.findAll();
    }

    public SearchResult<DocumentType> searchAndCount(Search search) {
        return this.documentTypeDao.searchAndCount(search);
    }

    public List<DocumentType> search(Search search) {
        return this.documentTypeDao.search(search);
    }

    public DocumentType searchUnique(Search search) {
        return this.documentTypeDao.searchUnique(search);
    }
    
}
